<template>
    <div class="app-container">
        <el-form ref="queryParamsRef" :inline="true" label-width="100" :model="queryParams">
            <el-row :gutter="20">
                <el-col :span="6">
                    <el-form-item label="部门受案号-重新入库">
                        <el-input v-model="queryParams.casecode" clearable @clear="getTableDataLists" style="width: 13vw;"/>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item label="案件名称">
                        <el-input v-model="queryParams.name" 
                        clearable 
                        @clear="getTableDataLists" 
                        @keyup.enter.prevent="getTableDataLists"
                        style="width: 13vw;"
                        />
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item label="出库日期">
                        <el-date-picker
                            v-model="dateRange"
                            value-format="YYYY-MM-DD"
                            type="daterange"
                            range-separator="-"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                            style="width:13vw"
                        ></el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item>
                        <el-button type="primary" @click="getTableDataLists">
                            <el-icon class="me-1">
                                <Search/>
                            </el-icon>
                            查询
                        </el-button>
                    </el-form-item>
                    <el-form-item>
                        <el-button @click="handleRest">
                            <el-icon class="me-1">
                                <Refresh/>
                            </el-icon>
                            重置
                        </el-button>
                    </el-form-item>
                </el-col>
                
            </el-row>
        </el-form>
        <el-divider class="mt-0 mb-3"/>
        <el-table
            ref="TableDataRef"
            v-loading="loading"
            :data="TablesData"
            show-overflow-tooltip
        >
            <el-table-column label="部门受案号" prop="name"/>
            <el-table-column label="案件名称" prop="casetype"/>
            
            <el-table-column label="承办人" prop="userName"/>
            <el-table-column label="入库日期" prop="casetype"/>
            <el-table-column label="赃证物类别" prop="state">
                <template #default="scope">
                    <dict-tag :options="nj_anjian_status" :value="scope.row.state"/>
                </template>
            </el-table-column>
            <el-table-column label="超高屏RFID码" prop="casetype"/>
            <el-table-column label="条码" prop="casetype"/>
            <el-table-column label="所在赃证物柜" prop="casetype"/>
            <el-table-column label="状态" prop="state">
                <template #default="scope">
                    <dict-tag :options="nj_anjian_status" :value="scope.row.state"/>
                </template>
            </el-table-column>
            <el-table-column fixed="right" align="center" label="操作" width="200">
                <template #default="scope">
                    <el-button
                        link size="small"
                        type="primary"
                        @click="Restorage"
                        >
                        <el-icon class="me-1">
                            <Edit/>
                        </el-icon>
                        重新入库
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination
            v-show="total > 0"
            :total="total"
            v-model:page="queryParams.pageNum"
            v-model:limit="queryParams.pageSize"
            @pagination="getTableDataLists"
        />
        <el-dialog
            v-model="dialogVisible"
            title="重新入库"
            width="600"
            @close="closeHandle"
        >
        <el-form ref="formRef" :model="form" label-width="120" :rules="rules">
            <el-form-item label="重新入库理由" required prop="zhengwutype">
                <el-input v-model="form.zhengwutype" clearable style="width: 100%;"/>
            </el-form-item>
            <el-radio-group v-model="form.zhengwutype">
                <el-radio value="公安重报" border>公安重报</el-radio>
                <el-radio value="公安二次重报" border>公安二次重报</el-radio>
                <el-radio value="法院退回" border>法院退回</el-radio>
                <el-radio value="承办人撤回" border>承办人撤回</el-radio>
            </el-radio-group>
        </el-form>
            <template #footer>
            <div class="dialog-footer">
                <el-button type="primary" @click="ConfirmRestorage">
                    确认重新入库
                </el-button>
                <el-button @click="dialogVisible = false">取消</el-button>
            </div>
            </template>
        </el-dialog>
    </div>
</template>

<script setup>
import { ElMessage, ElMessageBox } from 'element-plus'
const {proxy} = getCurrentInstance();
// import {getCaseInfoList,getCaseInfoInfo,  deleteCaseInfo} from "@/api/CaseInfo/CaseInfo";
import PageEnum from "@/enum/PageEnum.js";

const {sys_normal_disable,nj_anjian_status} = proxy.useDict('sys_normal_disable', 'nj_anjian_status')

const queryParamsRef = ref()
const loading = ref(false)
const dateRange = ref([])
const dialogVisible = ref(false)

const form = ref({})
const queryParams = ref({
    name: '',
    casecode: '',
     // 页码
     pageNum: 1,
    // 分页数量
    pageSize: PageEnum.SIZE
})

const total = ref(0)
const TablesData = ref([{
    name:'111',
}])
const rules = {
    zhengwutype: [{ required: true, message: "重新入库理由不能为空", trigger: "blur" }],
}
onMounted(() => {
    // getTableDataLists()
})

// 获取案件列表
const getTableDataLists = async () => {
    proxy.$modal.msgSuccess("获取案件");
    // loading.value = true
    // await getCaseInfoList(proxy.addDateRange(queryParams.value, dateRange.value)).then(res => {
    //     loading.value = false;
    //     TablesData.value = res.rows
    //     total.value = res.total;
    // });
}
const TableDataRef = ref()

const Restorage = () => {
    dialogVisible.value = true
}

const ConfirmRestorage = async () => {
    proxy.$refs["formRef"].validate(valid => {
        if (valid) {
            proxy.$modal.msgSuccess("确认重新入库");
        }
    });
}
// 关闭后的回调事件
const closeHandle = () => {
    form.value = {
        
    }
}
// 重置搜索调解
const handleRest = () => {
    queryParams.value = {
        name: '',
        casecode: '',
    }
    getTableDataLists()
}
</script>

<style lang="scss" scoped>

:deep() .el-radio__input{display: none;}
</style>